package com.ddone.controller;

import com.ddone.service.StockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ddone
 * @date 2024/4/6-14:38
 */
@RestController
@RequestMapping("/stock")
@Slf4j
public class StockController {

    @Value("${server.port}")
    private Integer port;

    @Resource
    private StockService stockService;

    @GetMapping("/{productId}/{count}")
    public Boolean updateStock(@PathVariable("productId") String productId,
                               @PathVariable("count") Integer count){

        log.warn("库存服务端口号: "+port);
        return stockService.updateStockByProductId(productId,count);
    }
}
